Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4522] Fix items order in inventory adjustment dropdown. #4541

Merged
merged 4 commits into from
Aug 1, 2024

Conversation

amanbhargav
Copy link
Contributor

Resolves #4522

Description

The items in the inventory adjustment dropdown were appearing in an unexpected order when adding a new storage location. This PR fixes the issue by ensuring that the items are sorted alphabetically in the controller before being passed to the view.

Solution:
Added .alphabetized scope to the inventory_items in the StorageLocationsController to ensure items are sorted alphabetically before being displayed.

Code Change:

# app/controllers/storage_locations_controller.rb
class StorageLocationsController < ApplicationController
  ...
  def inventory
    ...
    @inventory_items = StorageLocation.includes(inventory_items: :item)
                                      .find(params[:id])
                                      .inventory_items
                                      .alphabetized
                                      .active
    ...
  end
  ...
end

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

I have tested this change locally by:

  1. Creating a new storage location.
  2. Creating a new item to be added to the inventory.
  3. Adding a new inventory adjustment for that location.
  4. Verifying that the items in the dropdown are sorted alphabetically.

Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @amanbhargav - I haven't done a manual test, but it looks pretty obvious that that's the fix! Can you add an automated test that confirms the functionality (that's what we mean by "tests to confirm the functionality" in the criteria for completion, please?

@amanbhargav
Copy link
Contributor Author

@cielf Apologies for the delay in progress. I need to update the logic and write test cases, so I am working on both.

Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passes manual testing. @dorner Do you want to comment on the technical aspects?

@dorner
Copy link
Collaborator

dorner commented Aug 1, 2024

All good on my end too!

@dorner dorner merged commit 9916e0f into rubyforgood:main Aug 1, 2024
19 checks passed
Copy link
Contributor

@amanbhargav: Your PR [4522] Fix items order in inventory adjustment dropdown. is part of today's Human Essentials production release: 2024.08.11.
Thank you very much for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The order of items in inventory adjustment is a bit odd -- try it with a new storage location to see.
3 participants